<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>58.最后一个单词的长度</title>
</head>

<body>

</body>

<script>
    /**
     * @param {string} s
     * @return {number}
     */
    var lengthOfLastWord = function (s) {
        return s.trim().split(' ')[s.trim().split(' ').length - 1].length;
    };
    console.log(lengthOfLastWord("   fly me   to   the moon  "))
</script>

</html>